<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    pageContext.setAttribute("APP_PATH", request.getContextPath());
%>
<html>
<head>
    <title>Title</title>
    <%--     web路径问题：--%>
    <%--                 不以 / 开头：以当前资源路径为基准，容易出现问题--%>
    <%--                 以 / 开头：以服务器的路径为标准(http://localhost:3306),需要加上项目名--%>

    <link rel="stylesheet" href="${APP_PATH}/static/bootstrap/css/bootstrap.min.css"/>
    <script type="text/javascript" src="${APP_PATH}/static/jquery/jquery-3.5.1.min.js"></script>
</head>
<body>

<div class="container">
<%--    标题行--%>
    <div class="row">
        <div class="col-md-12"><h1>SSM-CRUD</h1></div>
    </div>
<%--    操作--%>
    <div class="row">
        <div class="col-md-4 col-md-offset-8">
            <button type="button" class="btn btn-info">
                <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>新增</button>
            <button type="button" class="btn btn-danger">
                <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>删除</button>
        </div>
    </div>
    <br>
<%--    显示表格数据--%>
    <div class="row">
        <table class="table table-hover">
            <tr>
                <th>ID</th>
                <th>姓名</th>
                <th>性别</th>
                <th>邮箱</th>
                <th>部门</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${pageInfo.list}" var="emp">
                <tr>
                    <td>${emp.empId}</td>
                    <td>${emp.empName}</td>
                    <td>${emp.gender == "M" ? "男" : "女"}</td>
                    <td>${emp.email}</td>
                    <td>${emp.dept.deptName}</td>
                    <td>
                        <button type="button" class="btn btn-info btn-sm">
                            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>新增</button>
                        <button type="button" class="btn btn-danger btn-sm">
                            <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>删除</button>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </div>
<%--    分页信息--%>
    <div class="row">
<%--        文字--%>
    <div class="col-md-6">
        当前${pageInfo.pageNum}页,总共${pageInfo.pages}页,总记录数:${pageInfo.total}
    </div>
<%--        分页条--%>
    <div class="col-md-12"><h1>
        <nav aria-label="Page navigation">
            <ul class="pagination pagination-lg">
                <li><a href="/emps?pageInfo=1">首页</a></li>
                <c:if test="${pageInfo.pageNum == 1}">
                    <li class="disabled">
                        <a href="#" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                </c:if>
                <c:if test="${pageInfo.pageNum > 1}">
                    <li>
                        <a href="/emps?pageNumber=${pageInfo.pageNum-1}" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                </c:if>

                <c:forEach items="${pageInfo.navigatepageNums}" var="num">

                    <c:if test="${pageInfo.pageNum == num}">
                        <li class="active"><a href="#">${num}</a></li>
                    </c:if>

                    <c:if test="${pageInfo.pageNum != num}">
                        <li><a href="/emps?pageNumber=${num}">${num}</a></li>
                    </c:if>

                </c:forEach>

                <c:if test="${pageInfo.pageNum == 200}">
                    <li class="disabled">
                        <a href="#" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                </c:if>
                <c:if test="${pageInfo.pageNum < pageInfo.pages}">
                    <li>
                        <a href="/emps?pageNumber=${pageInfo.pageNum+1}" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                </c:if>
                <li><a href="/emps?pageNumber=${pageInfo.pages}">尾页</a></li>
            </ul>
        </nav>
    </h1></div>
    </div>
</div>

</body>
</html>
